home *** CD-ROM | disk | FTP | other *** search
- /*[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]*/
- /*UAssociation.p*/
- /*Copyright © 1988-1990 by Apple Computer Inc. All rights reserved*/
- #ifndef __UAssociation__
- #define __UAssociation__ 0
- #endif
- #if ! __UAssociation__
- #define __UAssociation__ 1
-
- /* • Auto-Include the requirements for this unit's interface */
- #ifndef __UList__
- #include "UList.h"
- #endif
-
- class TEntry : public TObject {
- public: /* This class has two instances variables to
- store a key string and an associated value
- string*/
-
- StringHandle fKey; /* A handle to the 'keyStr'*/
- StringHandle fValue; /* A handle to the 'valueStr'*/
-
- virtual pascal void IEntry(StringPtr itsKey, StringPtr itsValue);
- /* Initialization routine*/
-
- virtual pascal void Free(void);
- /* Frees the fKey & fValue string handles then calls inherited free*/
-
- virtual pascal void SetValue(StringPtr value);
- /* Sets the fValue field to theValue*/
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields*/
-
- };
-
- class TEntriesList : public TSortedList {
- public: /* Subclass of TSortedList that manages a
- sorted list of TEntry objects, used as an
- instance variable in TAssociation*/
-
- virtual pascal void IEntriesList(void);
- /* Initialize the list */
-
- virtual pascal short Compare(TObject *item1, TObject *item2);
- /* Compares 'item'1 with 'item2' returning an integer indicating the results of the
- comparison*/
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields */
-
- };
-
- class TAssociation : public TObject {
- public: /* This class is used to create lists of
- strings that are accessed via their
- associated keys. The keys & strings are
- stored in TEntry objects which are in the
- TEntriesList instance variable*/
-
- TEntriesList *fEntries; /* The list of TEntries that stores the
- associations */
-
- virtual pascal void IAssociation(void);
- /* Initialization routine */
-
- virtual pascal void Free(void);
- /* Frees the instance variable fEntries */
-
- virtual pascal Boolean ValueAt(StringPtr keyStr, StringPtr valueStr);
- /* Given 'keyStr' returns the associated string in 'valueStr', with the result true
- if an associated string was found */
-
- virtual pascal Boolean KeyAt(StringPtr valueStr, StringPtr keyStr);
- /* Given 'valueStr' returns the associated key in 'keyStr', with the result true if
- an associated key was found */
-
- virtual pascal void EachEntryDo(pascal void (*DoToEntry)(TEntry *theEntry, void *
- DoToEntry_StaticLink), void *DoToEntry_StaticLink);
- /* Iterates over each entry passing it to "DoToEntry" */
-
- virtual pascal TEntry *EntryWithKey(StringPtr keyStr);
- /* Returns the Entry containing 'keyStr' */
-
- virtual pascal TEntry *EntryWithValue(StringPtr valueStr);
- /* Returns the entry containing 'valueStr' */
-
- virtual pascal TEntry *FirstEntryThat(pascal Boolean (*TestEntry)(TEntry *theEntry, void *
- TestEntry_StaticLink), void *TestEntry_StaticLink);
-
- /* Iterates over each entry passing it to "TestEntry" until the result of the Test is
- TRUE */
-
- virtual pascal void InsertEntry(StringPtr keyStr, StringPtr valueStr);
- /* Inserts an entry into thei association, if 'keyStr' already exists then the value
- is merely replaced with 'valueStr'. Otherwise a new Entry is created with the above
- 'keyStr' and 'valueStr' */
-
- virtual pascal void RemoveValueAt(StringPtr keyStr);
- /* Removes the value associated with 'keyStr' */
-
- virtual pascal void RemoveKeyAt(StringPtr valueStr);
- /* Removes the key associated with 'valueStr' */
-
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- /* Used by the Inspector and the Debugger to display the contents of this class's
- fields */
-
- };
-
- #endif
-
-